package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.AnnouncementMapper;
import com.tanhua.model.domain.Announcement;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class AnnouncementApiImpl implements AnnouncementApi{

    @Autowired
    private AnnouncementMapper announcementMapper;

    /*公告列表*/
    @Override
    public List<Announcement> findAll(Integer page, Integer pagesize) {
        //构造排序条件
        QueryWrapper<Announcement> qw=new QueryWrapper<>();
        qw.orderByDesc("created");
        //构造分页条件
        Page<Announcement> page1=new Page<>(page,pagesize);
        //调用announcementMapper进行查询
        Page<Announcement> announcementPage = announcementMapper.selectPage(page1,qw);
        List<Announcement> records = announcementPage.getRecords();
        return records;
    }
}
